package com.adams.log.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.adams.access.db.bean.OptLog;
import com.adams.log.dao.OptLogDao;
import com.adams.log.service.OptLogService;
import com.adams.log.task.OptLogQueue;
import com.adams.utils.Page;

/**
 * 
 * 
 * File Name : OptLogServiceImpl.java
 * 
 * @Description : 日志管理服务类，提供对日志的增、查功能
 * @author 902990封文进
 */
@Service("optLogService")
@Transactional
public class OptLogServiceImpl implements OptLogService
{

	@Autowired
	private OptLogDao optLogDao;

	public void setOptLogDao(OptLogDao optLogDao)
	{
		this.optLogDao = optLogDao;
	}

	/**
	 * 
	 * Description : Description : 创建日志
	 * 
	 * @param log
	 * 
	 */
	@Transactional(rollbackFor = java.lang.Exception.class)
	public void createLog(OptLog log)
	{
		OptLogQueue.addLog(log);
		// optLogDao.save(log);
	}

	/**
	 * 
	 * Description : 删除日志
	 * 
	 * @param log
	 * 
	 */
	@Transactional(rollbackFor = java.lang.Exception.class)
	public void delete(OptLog log)
	{
		optLogDao.delete(log);
	}

	/**
	 * 
	 * Description : 根据操作员和操作时间查询日志
	 * 
	 * @param page
	 * @param operator
	 * @param operateTime
	 * @return Page<OptLog>
	 * 
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public Page<OptLog> queryByCondition(Page<OptLog> page, String operator,
			Date operateTime)
	{
		return optLogDao.queryByCondition(page, operator, operateTime);
	}
}
